package edit;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Toolkit;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextField;
import javax.swing.ScrollPaneConstants;
import javax.swing.UIManager;

import view.MainFrame;
public class FeatureCAndSRulePanel extends JPanel {

	static JSplitPane ioSplitPane;
	static JScrollPane outputArea;
	static JScrollPane copyArea;
	
	private JComboBox copy;
	private JComboBox newName;
	private JComboBox defVal;
	
	public static void main(String[] args){
		try{
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		}catch(Exception e){}
		
		Font oldLabelFont = UIManager.getFont("Label.font");
		UIManager.put("Label.font", oldLabelFont.deriveFont(Font.PLAIN,(float)14));
		
		JFrame mainFrame = new JFrame();
		
		mainFrame.setSize(800,600);
		mainFrame.setExtendedState(Frame.MAXIMIZED_BOTH);
		//mainFrame.setUndecorated(true);
		mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		FeatureCAndSRulePanel f = new FeatureCAndSRulePanel();
		mainFrame.add(f.returnView());
		mainFrame.setVisible(true);
		
	}
	
	public FeatureCAndSRulePanel(){
		setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		FCSRightPanel rightPanel = new FCSRightPanel("Feature Copying and Setting Rules");
		
		JScrollPane inputArea = new JScrollPane();
		inputArea.setBorder(BorderFactory.createTitledBorder("Input"));
		
		outputArea = new JScrollPane();
		outputArea.setBorder(BorderFactory.createTitledBorder("Output"));
		
		copyArea = new JScrollPane();
		copyArea.setBorder(BorderFactory.createTitledBorder("Features to be Copied"));
		
		ioSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, inputArea, outputArea);
		ioSplitPane.setDividerLocation((int)(MainFrame.getInstance().getWidth()*2.0/5)+ioSplitPane.getInsets().bottom);
		
		JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, ioSplitPane, rightPanel);
		splitPane.setDividerLocation( (int)(MainFrame.getInstance().getWidth()*4.0/5 + splitPane.getInsets().left));
		splitPane.setDividerSize(0);
		
		this.add(splitPane);
		initializeCopyArea();
	}
	
	public void initializeCopyArea(){
		JPanel panel = new JPanel();  
		copyArea.setViewportView(panel);
		panel.setLayout(null);
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		double width = screenSize.getWidth();
		double height = screenSize.getHeight();
		int palettewidth = (int)(width*0.4);
		int paletteheight = (int)(height*0.2);
		this.setPreferredSize(new Dimension(palettewidth,paletteheight));
		addComponentsToCopyArea(panel);
	}
	
	public void addComponentsToCopyArea(JPanel panel){
		JLabel copyLbl = new JLabel("Feature to Copy: ");
		JLabel newNameLbl = new JLabel("New Name for Copied Feature: ");
		JLabel defValLbl = new JLabel("Default Value if Source NOT Available: ");
	
		copy = new JComboBox();
		newName = new JComboBox();
		defVal = new JComboBox();
		
		copyLbl.setBounds(5, 5, 200, 20);
		copy.setBounds(255, 5, 200, 20);
		newNameLbl.setBounds(5, 30, 200, 20);
		newName.setBounds(255, 30, 200, 20);
		defValLbl.setBounds(5, 55, 250, 20);
		defVal.setBounds(255, 55, 200, 20);
		
		
		panel.add(copy);
		panel.add(newName);
		panel.add(defVal);
		panel.add(copyLbl);
		panel.add(newNameLbl);
		panel.add(defValLbl);
	}
	
	
	public Component returnView(){
		return this;
	}
	
	public void setOutputAreaVisible(boolean b){
		
	}
}
